load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "optimizor",
    srcs = [
        "optimize_trace.go",
        "plan_replayer.go",
        "statistics_handler.go",
    ],
    importpath = "github.com/pingcap/tidb/server/handler/optimizor",
    visibility = ["//visibility:public"],
    deps = [
        "//domain",
        "//domain/infosync",
        "//infoschema",
        "//parser/model",
        "//parser/mysql",
        "//server/handler",
        "//session",
        "//sessionctx/variable",
        "//statistics/handle",
        "//table",
        "//types",
        "//util",
        "//util/logutil",
        "//util/replayer",
        "@com_github_burntsushi_toml//:toml",
        "@com_github_gorilla_mux//:mux",
        "@com_github_pingcap_errors//:errors",
        "@com_github_tikv_client_go_v2//oracle",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "optimizor_test",
    timeout = "short",
    srcs = [
        "main_test.go",
        "optimize_trace_test.go",
        "plan_replayer_test.go",
        "statistics_handler_test.go",
    ],
    flaky = True,
    shard_count = 4,
    deps = [
        ":optimizor",
        "//config",
        "//domain",
        "//kv",
        "//metrics",
        "//parser/model",
        "//server",
        "//server/internal/testserverclient",
        "//server/internal/testutil",
        "//server/internal/util",
        "//session",
        "//statistics/handle",
        "//store/mockstore/unistore",
        "//testkit",
        "//testkit/testsetup",
        "//util/topsql/state",
        "@com_github_burntsushi_toml//:toml",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_gorilla_mux//:mux",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//tikv",
        "@org_uber_go_goleak//:goleak",
    ],
)
